<template>
    <div>
        <div id="sheets"
            v-loading="getLoading.status" 
            :element-loading-text="getLoading.msg"
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.6)">
            
            <ul class="sheets-header">
                <li v-for="(item, index) in getTables" 
                    :class="{ 'sh-active':item.active }" 
                    @click="switchTable(index)"
                    :key="item.id"
                    v-dragging="{ item: item, list: getTables, group: 'item.id' }">

                    {{item.title}}
                    <span class="close" @click.stop="deleteTable(index)">
                        <i class="fa fa-close"></i>
                    </span>
                </li>
            </ul>
            
        
            <div id="sheets-box">

                <st-tabel
                    v-for="(item,index) in getTables" 
                    :hs_id="item.name"
                    :settings="item.settings"
                    :active="item.active"
                    :key="item.id"
                    v-show="item.active"
                    :index="index">

                </st-tabel>
            </div>
            <div id="footer">
                <div class="msg-bar">
                    &nbsp;
                    <span>ROW:{{setRowColNumber.row}}</span>
                    <span>COL:{{setRowColNumber.col}}</span>
                    <span>总共表格数:{{getTables.length}}</span>
                    <span>当前下标:{{getCurrentActiveTable.index}}</span>
                </div>
            </div>
        </div>

        <!-- 属性栏 -->
        <div id="property">
            <property> </property>
        </div>
        <!-- end 属性栏 -->
    </div>
</template>


<script>

import Vue from 'vue';
import {mapMutations,mapGetters} from 'vuex';
import VueDND from 'awe-dnd';//拖拽排序插件

import stTabel from "./stTable.vue";
import Property from '../views/property.vue'
Vue.use(VueDND);

class Dom{
    static autoHight(){
        let sheets=document.getElementById('sheets');
        let property=document.getElementById('property');
        sheets.style.height=(window.innerHeight-92)+'px';
        property.style.height=(window.innerHeight-82)+'px';
    }
}
export default {
    data(){
        return {
            loading:true,
            sheetsActive:[]
        }
    },
    computed:{
        ...mapGetters(['getTables','getCurrentActiveTable','getLoading','setRowColNumber']),
    },
    mounted(){
        Dom.autoHight();
        this.$dragging.$on('dragged', ({ value }) => {
            
        });
        let tables=this.getTables;
        //console.log('sheets',tables);
        tables=[];
        //console.log('sheets',this.getTables);
    },
   
    methods:{
        ...mapMutations(['switchTable','deleteTable']),
    },
    components: {
        stTabel,
        Property
    }
   
}
</script>

<style scoped>
#sheets{
    margin-top: -1px;
    width: 80%;
    float: left;
}
#property{
    float: left;
    width: 20%;
    background: #545c64;
}
#sheets-box{
    overflow: auto;
}
.sheets-header{
    position: relative;
    height: 31px;
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    background: #eee;
}
.sheets-header li{
    padding: 7px 10px;
    margin: 0;
    height: 16px;
    float: left;
    cursor: pointer;
    min-width: 80px;
    border-right: 1px solid #ccc;
    font-size: 12px;
}
.sh-active{
    background:#fff;
    color:#409EFF;
    border-bottom: #409EFF 1px solid;
}
.sheets-header li:hover{
    background: #409EFF;
    color:#fff;
}
.sheets-header li:hover span{
    display: inline-block;
    border-radius: 10px;
    float: right;
    position:relative;
}
.sheets-header li span{
    display: none;
    height: 16px;
    width: 16px;
    font-size: 10px;
    text-align: center;
    line-height: 16px;
    border-radius: 10px;
}
.sheets-header li span:hover{
    background: #F56C6C;
    color:#fff;
}
.msg-bar{
    width: 100%;
    height: 20px;
    background: #545c64;
    color:#fff;
    position:absolute;
    bottom: 0;
    font-size: 12px;
}
.msg-bar span{
    display: inline-block;
    line-height: 20px;
    padding:0 5px;
}
.msg-bar span:hover{
   display: inline-block;
   cursor: pointer;
   background: #409EFF
}
</style>
